package org.kl.bf.entity;

import javax.persistence.JoinColumn;
import javax.persistence.MappedSuperclass;
import javax.persistence.OneToOne;

import org.hibernate.annotations.Formula;
import org.kl.bf.entity.basic.AttachmentMaster;

/**
* 含审计信息和附件的Entity基类.
 * @author Qken
 * @date 2014年5月8日
 */
@MappedSuperclass
public abstract class AttachmentEntity extends AuditableEntity{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private AttachmentMaster attachmentMaster;//附件
	private Integer attachCnt;
	
	@OneToOne
	@JoinColumn(name="attachmentId")
	public AttachmentMaster getAttachmentMaster() {
		return attachmentMaster;
	}

	public void setAttachmentMaster(AttachmentMaster attachmentMaster) {
		this.attachmentMaster = attachmentMaster;
	}
	
	@Formula("(select count(*) from BASIC_ATTACHMENT_DETAIL ad where ad.attachment_master_id= attachment_id)")
	public Integer getAttachCnt() {
		return attachCnt;
	}

	public void setAttachCnt(Integer attachCnt) {
		this.attachCnt = attachCnt;
	}

	/**
	 * 业务单据号
	 * @return
	 */
	public abstract String businessCode();
	
	/**
	 * 一级目录
	 * @return
	 */
	public abstract String levelType1();
	
	 /**
	  * 二级目录
	  * @return
	  */
	public abstract String levelType2();
}
